#ifndef MONITORINGUSERSQLITE_H
#define MONITORINGUSERSQLITE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>
#include <QFileInfo>
#include "MonitooringConfig.h"
#include "userModel.h"
#include "MonitoringTool.h"
#include <QJsonObject>
#include <QJsonDocument>
#include "deviceModel.h"
#include "dataModel.h"
#include "warnRoleModel.h"
#include "warnRecode.h"
class MonitoringUserSqlite : public QObject
{
    Q_OBJECT
public:


public:
    // 获取单例实例的静态方法
    static MonitoringUserSqlite& getInstance();

    bool openSqLite(const QString&);
    bool createSqLite(const QString&);
    QueryResult insertData(const QString&,const QString&,const QString&,const QString&);
    QueryResult isUserExists(const QString&);//查询用户是否存在
    QueryResult changePassword(const QString&,const QString&);//修改密码
    QueryResult loginGetData(const QString&,const QString&);//登录
    QueryResult changeEmail(const QString&,const QString&);//修改邮箱

    bool optionsUserSqLite();
    bool optionsDeviceSqLite();
    bool optionsDataSqLite();
    bool optionsWarnRoleSqLite();
    bool optionsWarnRecodeSqLite();
    QueryResult insertDeviceData(const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&);
    userModel*  getSqLite(const QString&);

    QList<deviceModel> checkList();
    QueryResult deviceDelete(const QString&);//删除设备
    QueryResult deviceUpdate(const QString&,const QString&,const QString&,const QString &);//更新设备

    QueryResult insertDataData(const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&);//插入数据
    QList<dataModel> selectAllDataData();//查询所有数据
    QList<dataModel> selectDataToReasonData(const QString&,const QString&,const QString&);//根据条件查询数据
    // 禁止拷贝构造函数和赋值运算符
    MonitoringUserSqlite(const MonitoringUserSqlite&) = delete;
    MonitoringUserSqlite& operator=(const MonitoringUserSqlite&) = delete;

    QueryResult insertWarnRoleData(const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&);//插入警告规则数据
    warnRoleModel*  getWarnRoleSqLite(const QString&);
    QueryResult insertWarnRecodeData(const QString&,const QString&,const QString&,const QString&);//插入警告记录数据
    QList<warnRecode> getWarnRecodeData();
    QList<deviceModel>  getDeviceGroupListSqLite(const QString&);
private:
    QSqlQuery query;
    QSqlDatabase db;
    // 私有析构函数，防止外部删除
    ~MonitoringUserSqlite();
    explicit MonitoringUserSqlite(QObject *parent = nullptr);
};

#endif // MONITORINGUSERSQLITE_H
